package com.tee.rocketmqstudy.demo;

import com.tee.rocketmqstudy.constant.MqConstant;
import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.client.producer.SendResult;
import org.apache.rocketmq.common.message.Message;
import org.junit.Test;

/**
 * @author tee
 * @date 2025/9/11
 */
public class HKeyTest {

    @Test
    public void testKeyProducer() throws Exception {
        // 创建默认的生产者
        DefaultMQProducer producer = new DefaultMQProducer("key-group");
        // 设置nameServer地址
        producer.setNamesrvAddr(MqConstant.NAME_SRV_ADDR);
        // 启动实例
        producer.start();

        Message msg1 = new Message("keyTopic","tag1","key1", "我是一个带标记的消息".getBytes());
        SendResult send = producer.send(msg1);
        System.out.println(send);
        // 关闭实例
        producer.shutdown();
    }


}
